package com.whately.core.base.utils;

import java.util.Optional;

public class IntegerUtils {


    //参数允许为null
    public static int integerToIntIncludeNull(Integer i) {
        return Optional.ofNullable(i).orElse(0);
    }

    public static boolean isPlusIntegerOrLong(String str) {
        if (str == null) {
            return false;
        }
        int sz = str.length();
        for (int i = 0; i < sz; i++) {
            if (Character.isDigit(str.charAt(i)) == false) {
                return false;
            }
        }
        return true;
    }

    //产生随机整数【min,max】
    public static int random(int min ,int max){
        int random = (int)(min+Math.random()*(max-min+1));
        return random;
    }

}
